#include "catch.hpp"

#include "common/log.h"
#include "config/cfg.h"
#include "common/path.h"


TEST_CASE("config tests", "[config]") {
    using namespace std;
    using namespace evm;
    using namespace evm::config;

    init_log("config_tests", false, true);

    SECTION("json format config file") {
        string json_file = "tests/config_files/normal.json";
        REQUIRE(path::exists(json_file));

        auto conf = ConfigOpts("config_test", json_file);

        conf.register_opt<double>("pi", 0, true, "PI");
        conf.register_opt<bool>("happy", false, false, "Happy");
        conf.register_opt<string>("name", "None", false, "Name");
        conf.register_opt<Json>("answer", Json::object(), false, "Answer");
        conf.register_opt<Json>("list", {0, 1, 2}, false, "List");
        conf.register_opt<Json>("object", Json({}), false, "Object");

        conf.register_cli_opt<string>("host", "localhost", false, "host", "address");

        conf();

        conf.log();
    }
}
